/**
 * 竞争信息 - 编辑页面
 * @author miaoyl
 * @date 2019/04/22
 */
define(function () {

    var self,
        app = win.app,
        doc = document,
        vueData = {
            form: '',
            rules: {
                GWBJ001: [
                    {required: true, message: '不可为空', trigger: 'blur'}
                ],
                GWBJ002: [
                    {required: true, message: '不可为空', trigger: 'blur'}
                ],
                GWBJ005: [
                    {required: true, message: '不可为空', trigger: 'blur'}
                ],
                GWBJ003: [
                    {required: true, message: '不可为空', trigger: 'blur'}
                ],
                GWBJ004: [
                    {required: true, message: '不可为空', trigger: 'blur'}
                ]
            },
            selectOptions:{
                crm_gwat160_gwbj005:app.datas_("crm_gwat160_gwbj005")
            },
        },
        callObj
    ;

    var Gwat160Edit = app.Module.extend({
        init: function () {
            self = this;
            self._super({
                _tag: 'gwat160_edit_gwbj',
            }, win);
        },

        addData: function () {
            app.ajax({
                xurl: 'crm/gwat160/addGwbj',
                xdata: vueData.form,
                loading: true,
                okmsg: '信息保存成功',
                cb: function (result) {
                    if (result.ok) {
                        app.pageModule('gwat160_edit').getTable3();
                        self._closeTpl();
                    }
                }
            });
        },

        _call: function (obj) {
            vueData.form.GWBJNAME = obj.GWBHNAME;
            vueData.form.GWBJID = obj.GWBHID;
            vueData.form.GWBJSEQ = obj.GWBJSEQ;
        },
        _ready: function () {
            vueData.form = app.fields_(['GWBJ_T']);
            var vue = new Vue({
                el: '#gwat160_edit_gwbj',
                data: vueData,
                methods: {
                    cancel: function () {
                        layer.close(layer.index);
                    },
                    sure: function () {
                        this.$refs['form'].validate(function (valid) {
                            if (valid) {
                                self.addData();
                            }
                        });
                    }
                },
                watch: {},
                created: function () {
                    self._setEleIsReady('gwat160_edit_gwbj');
                }
            });
        },

        _lazy: function () {
            this._super();
        }
    });

    return new Gwat160Edit();

});